#include <iostream>
#include <fstream>
#include <Windows.h>
#pragma comment(lib, "user32.lib")

HHOOK keyboardHook{ NULL };
HHOOK mouseHook{ NULL };

LRESULT CALLBACK MyLowLevelKeyBoardProc(const int nCode, const WPARAM wParam, const LPARAM lParam)
{
	switch (wParam)
	{
	case WM_KEYDOWN:
		std::cout << "KeyDown event occured." << std::endl;
		break;
	case WM_KEYUP:
		std::cout << "KeyUp event occured." << std::endl;
		break;
	}

	return CallNextHookEx(keyboardHook, nCode, wParam, lParam);
}

LRESULT CALLBACK MyLowLevelMouseProc(const int nCode, const WPARAM wParam, const LPARAM lParam)
{
	switch (wParam)
	{
	case WM_LBUTTONDOWN:
		std::cout << "MouseLeftButtonDown event occured." << std::endl;
		break;
	case WM_RBUTTONDOWN:
		std::cout << "MouseRightButtonDown event occured." << std::endl;
		break;
	}

	return CallNextHookEx(mouseHook, nCode, wParam, lParam);
}

int main(int argc, char* argv[])
{
	keyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, MyLowLevelKeyBoardProc, NULL, 0);
	if (keyboardHook == NULL) {
		std::cout << "Keyboard hook failed!" << std::endl;
	}

	mouseHook = SetWindowsHookEx(WH_MOUSE_LL, MyLowLevelMouseProc, NULL, 0);
	if (mouseHook == NULL) {
		std::cout << "Mouse hook failed!" << std::endl;
	}

	while (GetMessage(NULL, NULL, 0, 0));
	return 0;
}